-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adding PR Build and Deploy actions for all PRs #1056
feat: Adding PR Build and Deploy actions for all PRs #1056
Conversation
This PR is being prevented from merging because Review Required. Use the Approved label to run build validation and auto merge the PR. |
Noted will review. Small point in regards to the following:
Quick first question is does this change overwrite the current functionality of having a preview build for any feature branch (on main repo) that has a PR to If no we don't really need to build other branches unless they are PR'd since they are just technically working feature branches. I know that vercel did this and allowed us to technically preview feature branches that did not have a PR but we never really needed to use this feature. Second question - with the current iteration of this PR if I created a PR as previously for say
Would the second bullet point still generate a PR preview? |
@Valastiri The initial suggestion from the custom action we are using here, is to completely disable Cloudflare Github direct integration. Which means no CF Automatic builds on Production (Primary) branch. If we do that, we would also need to create a similar workflow for changes on the primary branch (and optionally one for feature branches). But I find CF building the primary branch automatically is probably a nice thing. And have PRs be managed by these workflows.
Yep, any PR would generate a preview. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have no way to test it other the merge and test it I'd say let's go for it and see if we need to change something later.
Summary
Uses https://github.com/marketplace/actions/refined-cloudflare-pages-action#enabling-pr-previews-from-forks for building and deploying PR Previews to Cloudflare pages.
Setup
Requires a few new secrets:
CLOUDFLARE_PAGES_API_TOKEN
- Specific API Token with access to editing Cloudflare Pages for the accountCLOUDFLARE_PAGES_ACCOUNT_ID
- API Account ID for Cloudflare Pages, this could be the same as the main account, but might be good to split up in case we ever need to have flexibility.CLOUDFLARE_DOCS_PROJECT
- The Pages project in Cloudflare for the docs site specifically.On Cloudflare Pages, it is best to only allow automatic building of the main branch (primary) of the main repo, and not other branches, although this is not a must. If building all branches remains enabled, if a PR is created for a branch on the main repo, two deployments will exist for the PR. One for the branch, and one for the PR itself (using this change).
Functionality
This is a two-stepped approach so that PRs do not need access to secrets (fork PRs have no access to secrets of the main repo):
<repo-owner>-<branch>.<project>.pages.dev
.Proof of concept
Both have been deployed on CF Pages as previews, with multiple commits (create PR, and adding more commits after):
Note that in this test deployment, only Primary (production) branch is enabled for automatic build. For other branches on the main repo, the automatic builds are disabled.